# -*- coding: utf-8 -*-
# @Time : 2021/2/2 8:31
# @Author : 加钱哥
# @Email : scg@gmail.com
# @File : login_page.py
# @Project : xiangmu

from selenium import webdriver
from selenium.webdriver.common.by import By
from pages.base_page import BasePage

class LoginPage(BasePage):
    """定义登录页面"""
    url_ = "http://192.168.1.14/crm/index.php?m=user&a=login"
    username_locator = (By.NAME,"name")
    password_locator = (By.NAME,"password")
    submit_locator = (By.NAME,"submit")

    def submit(self):
        return self.findE(self.submit_locator).click()

    def username(self,username):
        return self.driver.find_element(*self.username_locator).send_keys(username)

    def password(self,password):
        return self.driver.find_element(*self.password_locator).send_keys(password)

    def login(self,username,password):
        self.open()
        self.username(username)
        self.password(password)
        self.submit()

